package gunfire.potions;

import com.megacrit.cardcrawl.characters.AbstractPlayer;
import com.megacrit.cardcrawl.core.AbstractCreature;
import com.megacrit.cardcrawl.core.CardCrawlGame;
import com.megacrit.cardcrawl.core.Settings;
import com.megacrit.cardcrawl.dungeons.AbstractDungeon;
import com.megacrit.cardcrawl.helpers.PowerTip;
import com.megacrit.cardcrawl.localization.PotionStrings;
import com.megacrit.cardcrawl.potions.AbstractPotion;
import com.megacrit.cardcrawl.rooms.AbstractRoom.RoomPhase;
import com.megacrit.cardcrawl.vfx.ThoughtBubble;
import gunfire.GunfireMod;
import gunfire.actions.ElementalEffectAction;

public class ElementEffectPotion extends AbstractPotion {
    public static final String POTION_ID = GunfireMod.makeID("ElementEffectPotion");
    private static final PotionStrings potionStrings = CardCrawlGame.languagePack.getPotionString(POTION_ID);
    public static final String NAME = potionStrings.NAME;
    public static final String[] DESCRIPTIONS = potionStrings.DESCRIPTIONS;

    public ElementEffectPotion() {
        super(potionStrings.NAME, POTION_ID, PotionRarity.COMMON, PotionSize.BOLT, PotionColor.SWIFT);
        this.isThrown = false;
        this.targetRequired = true;
    }

    public int getPotency(int ascensionLevel) {
        return 3;
    }

    public void initializeData() {
        this.potency = this.getPotency();
        this.description = potionStrings.DESCRIPTIONS[0] + this.potency + potionStrings.DESCRIPTIONS[1];
        this.tips.clear();
        this.tips.add(new PowerTip(this.name, this.description));
    }

    public void use(AbstractCreature target) {
        AbstractPlayer p = AbstractDungeon.player;
        if (AbstractDungeon.getCurrRoom().phase == RoomPhase.COMBAT) {
            int type = AbstractDungeon.potionRng.random(2);
            if(type == 0){
                AbstractDungeon.effectList.add(new ThoughtBubble(AbstractDungeon.player.dialogX, AbstractDungeon.player.dialogY, 3.0F,
                        Settings.language == Settings.GameLanguage.ZHS ? "火焰异常。" : "Burning.",
                        true));
                this.addToBot(new ElementalEffectAction(target, p, this.potency, GunfireMod.ElementalEffect.Burning));
            } else if(type == 1){
                AbstractDungeon.effectList.add(new ThoughtBubble(AbstractDungeon.player.dialogX, AbstractDungeon.player.dialogY, 3.0F,
                        Settings.language == Settings.GameLanguage.ZHS ? "腐蚀异常。" : "Decay.",
                        true));
                this.addToBot(new ElementalEffectAction(target, p, this.potency, GunfireMod.ElementalEffect.Decay));
            } else {
                AbstractDungeon.effectList.add(new ThoughtBubble(AbstractDungeon.player.dialogX, AbstractDungeon.player.dialogY, 3.0F,
                        Settings.language == Settings.GameLanguage.ZHS ? "雷电异常。" : "Shock.",
                        true));
                this.addToBot(new ElementalEffectAction(target, p, this.potency, GunfireMod.ElementalEffect.Shock));
            }
        }
    }

    public AbstractPotion makeCopy() {
        return new ElementEffectPotion();
    }

}
